package twentytwenty;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-08 12:28
 * @Modified By:
 */
public class IsIsomorphic_205 {
    public static void main(String [] args){
        String s = "eggg", t = "daad";
        System.out.println(isIsomorphic(s, t));
    }

    public static boolean isIsomorphic(String s, String t) {
        int sLength = s.length();
        char [] sArr = new char[sLength];
        char [] tArr = new char[sLength];
        for (int i = 0; i < sLength; i++) {
            sArr[i] = s.charAt(i);
            tArr[i] = t.charAt(i);
        }
        int[] preIndexOfs = new int[256];
        int[] preIndexOft = new int[256];
        for (int i = 0; i < sLength; i++) {
            if (preIndexOfs[sArr[i]] != preIndexOft[tArr[i]]) {
                return false;
            }
            preIndexOfs[sArr[i]] = i + 1;
            preIndexOft[tArr[i]] = i + 1;
        }
        return true;
    }
}
